package com.itheima;

import java.util.ArrayList;
import java.util.Iterator;

public class Demo5Student {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student s1 = new Student("吕布","001",18);
        Student s2 = new Student("赵云","002",19);
        Student s3 = new Student("典韦","003",20);

        list.add(s1);
        list.add(s2);
        list.add(s3);

        for (Student student : list) {
            System.out.println(student);
        }
        System.out.println("------------------");
        Iterator<Student> it = list.iterator();
       while (it.hasNext()){
           Student next = it.next();
           System.out.println(next);
       }
    }
}
